package net.xuele.learn.concurrent;

import java.util.concurrent.CountDownLatch;

/**
 * @Author: yubo
 * @date: 14:46 2020/4/20
 * @Description: 类描述
 */

public class PartickFuture<T> {
    private T data;
    private CountDownLatch latch = new CountDownLatch(1);

    public T get() {
        try {
            latch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return data;
    }

    public void setData(T data) {
        this.data = data;
        latch.countDown();
    }
}
